library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity set is
    port(choice: in std_logic_vector(2 downto 0);
        add: in std_logic;
        qout1: out std_logic_vector(23 downto 0));
end;

architecture art of set is

--？这些变量没有初始值，难道是要分配引脚吗
--小时
signal temph12: std_logic_vector(3 downto 0);
signal temph22: std_logic_vector(3 downto 0);
--分钟
signal tempm12: std_logic_vector(3 downto 0);
signal tempm22: std_logic_vector(3 downto 0);
--秒
signal temps12: std_logic_vector(3 downto 0);
signal temps22: std_logic_vector(3 downto 0);
--输出
signal tempqout: std_logic_vector(23 downto 0);

begin

process(choice,add)
begin

if(add'event and add='1')then
    if(choice="000")then
		if(temph12="0010")then
				temph12<="0000";
		else
				temph12<=temph12+"0001";
		end if;
    end if;

    if(choice="001") then
		if((temph12<"0010"and temph22="1001")or(temph12="0010" and temph22="0011"))then
				temph22<="0000";                 
		else
				temph22<=temph22+1; 
		end if;
    end if;
 
    if(choice="010" )then
		if(tempm12="0101")then
			tempm12<="0000";
		else
			tempm12<=tempm12+1;
		end if;
    end if;
    
    if(choice="011")then
		if(tempm22="1001")then
			tempm22<="0000";
		else
			tempm22<=tempm22+1;
		end if;
     end if;
 
     if(choice="100")then
		if(temps12="0101")then
			temps12<="0000";
		else
			temps12<=temps12+'1';
		end if;
     end if;
    
     if(choice="101")then
		if(temps22="1001")then
			temps22<="0000";
		else
			temps22<=temps22+1;
		end if;
     end if;
end if;

    tempqout <= temph12 & temph22 & tempm12 & tempm22 & temps12 & temps22; 
    qout1<=tempqout;

end process;
end art;
